/**
 * 
 */
package org.istt.service.impl;

import java.util.List;

import org.istt.dao.ReportDao;
import org.istt.domain.Report;
import org.istt.service.ReportManager;
import org.istt.web.helper.ExtendedPaginatedList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Ndtho
 *
 */
@Service("reportManager")
public class ReportManagerImpl extends ManagerImpl<Report, Long> implements ReportManager {
	
	/**
	 * @param categoryDao the categoryDao to set
	 */
	@Autowired
	public void setReportDao(ReportDao dao) {
		this.dao = dao;
	}

	@Override
	public ExtendedPaginatedList getReportList( ExtendedPaginatedList paginatedList) {
		// TODO Auto-generated method stub
		List<Report> results = ((ReportDao)dao).getReportList(paginatedList
                .getFirstRecordIndex(), paginatedList.getPageSize(), paginatedList
                .getSortDirection(), paginatedList.getSortCriterion());
			
        paginatedList.setList(results);
        paginatedList.setTotalNumberOfRows(((ReportDao)dao).getRecordCount());
		return paginatedList;
	}

	@Override
	public ExtendedPaginatedList searchReport(String name,
			ExtendedPaginatedList paginatedList) {
		// TODO Auto-generated method stub
		List<Report> results = ((ReportDao)dao).searchReport(name, paginatedList
                .getFirstRecordIndex(), paginatedList.getPageSize(), paginatedList
                .getSortDirection(), paginatedList.getSortCriterion());
		
		paginatedList.setList(results);
        paginatedList.setTotalNumberOfRows(((ReportDao)dao).getSearchRecordCount(name));
        
		return paginatedList;
	}
	
}
